package com.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Controller
public class ReturnController {

    @RequestMapping("/returnVoid")
    public void returnVoid(HttpSession session){
        session.setAttribute("userName","张三");
        System.out.println("returnVoid....");

    }

    @RequestMapping("/returnVoid2")
    public void returnVoid2(
            HttpServletRequest request,
            HttpServletResponse response,
            HttpSession session) throws ServletException, IOException {
        System.out.println("returnVoid2....");
        //转发
        request.getRequestDispatcher("/WEB-INF/jsp/success.jsp").forward(request,response);

    }

    @RequestMapping("/returnVoid3")
    public void returnVoid3(
            HttpServletRequest request,
            HttpServletResponse response,
            HttpSession session) throws ServletException, IOException {
        System.out.println("returnVoid3....");
        //重定向
        response.sendRedirect("/returnVoid");

    }

}
